/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package embeddedpaint.user_interface.tools.dialog;

import com.sun.org.apache.bcel.internal.generic.ARRAYLENGTH;
import embeddedpaint.model.layers.LayerManager;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.HeadlessException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.ArrayList;
import java.util.Observer;
import javax.swing.JButton;
import javax.swing.JColorChooser;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JSpinner;

public class FrameDrawPen extends ToolFrame
{
    private static final Color       M_DEFAULT_COLOR                    = Color.BLACK;
    private static final String      M_FRAME_TITLE                      = "Options Draw Pen";
    private static final String      M_SUBFRAME_COLOR_CHOOSER_TITLE     = "Color Chooser";
    private LayerManager             m_imageManager;
    private JButton                  m_buttonColor                      = new JButton("Select color");
    private Dimension                m_dimension                        = new Dimension(250,150);
    private Color                    m_color;
    private JFrame                   m_frameColor;

    public FrameDrawPen (LayerManager imageManager, JFrame application) 
    {
        this.m_color        = M_DEFAULT_COLOR;
        this.m_imageManager = imageManager;
        
        this.setTitle(M_FRAME_TITLE);
        this.setSize(m_dimension);
        this.setVisible(rootPaneCheckingEnabled);
        this.setLayout(new GridLayout(1,1));
        this.add(m_buttonColor);
        
        updateObserver(G_UPDATE_KEY_VALUE_CHANGED);
        
        m_buttonColor.addActionListener(new ActionListener()
        {
            @Override
            public void actionPerformed (ActionEvent e)
            {
                final JColorChooser colorChooser = new JColorChooser();
                m_color = colorChooser.showDialog(m_frameColor, M_SUBFRAME_COLOR_CHOOSER_TITLE,  m_color);
               
                updateObserver(G_UPDATE_KEY_VALUE_CHANGED);
            }
        });
    }
    
    public Color getM_color ()
    {
        return m_color;
    }
    
    public void close ()
    {
        this.setEnabled(true);
        this.dispose();
        this.updateObserver();
    }
}
